//
//  FunctionTableViewCell.m
//  Stream
//
//  Created by shaw on 16/8/7.
//  Copyright © 2016年 showshaw. All rights reserved.
//

#import "FunctionTableViewCell.h"
#import "FunctionItem.h"
#import "UIImageView+WebCache.h"
#import "Global.h"
@interface FunctionTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *titleLable;
@property (weak, nonatomic) IBOutlet UILabel *descLable;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UIButton *focusButton;

@end


@implementation FunctionTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    _focusButton.layer.cornerRadius = 2;
    _focusButton.layer.masksToBounds = YES;
}




-(void)setItem:(FunctionItem *)item
{
    _item = item;
    
    if (item) {
        _titleLable.text = item.name;
        _descLable.text = item.desc;
        [_iconImageView sd_setImageWithURL:[NSURL URLWithString:item.iconUrl] placeholderImage:[UIImage imageNamed:@"community_function_icon"]];
        
        
        if(item.isFocused)
        {
            [_focusButton setTitle:@"已关注" forState:UIControlStateNormal];
            _focusButton.backgroundColor = RGBColor(160,160,160,1.0);
            
        }
        else
        {
            [_focusButton setTitle:@"关注" forState:UIControlStateNormal];
            _focusButton.backgroundColor = RGBColor(51,149,250,1.0);
            
        }
    }
}

//click
- (IBAction)didClickFocusButton:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(functionTableViewCellDidClickFucusButton:)]) {
        [self.delegate functionTableViewCellDidClickFucusButton:self];
    }
}


@end
